package logic

import (
	"context"
	"video-system/userrpc/userrpc"

	"video-system/api/internal/svc"
	"video-system/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type VideoCountLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewVideoCountLogic(ctx context.Context, svcCtx *svc.ServiceContext) *VideoCountLogic {
	return &VideoCountLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *VideoCountLogic) VideoCount(req *types.VideoCountRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	count, err := l.svcCtx.UserRpc.VideoCount(l.ctx, &userrpc.VideoCountRequest{
		VideoId: req.VideoId,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Data:    nil,
			Code:    500,
		}, nil
	}

	return &types.Response{
		Message: "查询成功",
		Data:    count,
		Code:    200,
	}, nil

}
